<template>
  <div class="node ksampler">
    <div class="node-header">
      <span class="node-title">{{ nodeData._meta.title }}</span>
      <span class="node-type">{{ nodeData.class_type }}</span>
    </div>
    
    <div class="node-content">
      <div class="node-inputs">
        <!-- 数值输入 -->
        <div class="input-group">
          <div class="input-field">
            <label>采样器</label>
            <div class="input-value">{{ nodeData.inputs.sampler_name }}</div>
          </div>
          <div class="input-field">
            <label>步数</label>
            <input 
              type="number" 
              v-model="nodeData.inputs.steps"
              step="1"
            >
          </div>
          <div class="input-field">
            <label>CFG Scale</label>
            <input 
              type="number" 
              v-model="nodeData.inputs.cfg"
              step="0.1"
            >
          </div>
          <div class="input-field">
            <label>种子</label>
            <input 
              type="number" 
              v-model="nodeData.inputs.seed"
              step="1"
            >
          </div>
        </div>

        <!-- 连接点 -->
        <div class="connections">
          <div class="connection-point">
            <span class="connection-label">模型</span>
            <div class="connection-value">{{ formatConnection(nodeData.inputs.model) }}</div>
          </div>
          <div class="connection-point">
            <span class="connection-label">正向提示</span>
            <div class="connection-value">{{ formatConnection(nodeData.inputs.positive) }}</div>
          </div>
          <div class="connection-point">
            <span class="connection-label">负向提示</span>
            <div class="connection-value">{{ formatConnection(nodeData.inputs.negative) }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  nodeData: {
    type: Object,
    required: true
  },
  nodeId: {
    type: String,
    required: true
  }
})

const formatConnection = (connection) => {
  if (Array.isArray(connection)) {
    return `节点 ${connection[0]} 的输出 ${connection[1]}`
  }
  return connection
}
</script>

<style scoped>
.node {
  background: #2a2a2a;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  color: #fff;
}

.node-header {
  background: #383838;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.node-title {
  font-weight: bold;
  font-size: 14px;
}

.node-type {
  font-size: 12px;
  padding: 2px 6px;
  background: #42b883;
  border-radius: 4px;
}

.node-content {
  padding: 12px;
}

.input-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-field label {
  color: #aaa;
  font-size: 12px;
}

input {
  background: #383838;
  border: 1px solid #4a4a4a;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  width: 100%;
}

.connections {
  border-top: 1px solid #383838;
  padding-top: 8px;
}

.connection-point {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.connection-label {
  color: #aaa;
  font-size: 12px;
}

.connection-value {
  font-size: 12px;
  color: #42b883;
}
</style> 